Sociodemográfico

Column 1

Encuestados de regiones y distritos no adscritos a Lima Metropolitana

1,041

Encuestados de Lima Metropolitana

2,378

Resumen

Encuesta Ciudadana ICPCovid

"Los gráficos a continuación son el resultado de la primera encuesta ciudadana ICPCovid realizada en Perú durante la 2da semana de junio de 2020.

En total participaron 3419 personas de distintos distritos, provincias y regiones del Perú."

Column 2

Características

Column 3

Perú

Lima Metropolitana

Vida Diaria

Column 1

Resumen

Vida diaria durante la cuarentena

"La mayoría de personas reportó informarse a través de fuentes o medios oficiales en la web, seguido de redes sociales y la televisión. En menor medida, algunos mencionaron el uso de periódico y radio.

Al momento de la encuesta, casi la totalidad de los participantes mencionaron utilizar mascarillas al salir de sus casas. Asimismo, solo el ~20% de los niños salían de sus hogares.

La mayoria de personas solo salían una o dos veces de su hogar para dirigirse a mercados, farmacias o bancos. Aquellos que salieron tres o más veces se dirigieron principalmente a sus centros laborales."

Medios de información

Uso de mascarilla

Niños fuera de casa

Column 2

Destinos

Vida Profesional

Column 1

Resumen

Vida laboral y profesional durante la pandemia

"La pandemia y, en consecuencia, la cuarentena, afectó en mayor proporción a aquellos encuestados que reportaron un menor ingreso familiar. Aquellos con menores ingresos familiares dejaron de estudiar o trabajar más que aquellos con mayores ingresos.

No hubieron diferencias visuales significativas entre el ingreso familiar promedio y el número de salidas fuera del hogar.

La principal medida de protección de los centros laborales fue el que sus trabajadores permanezcan en casa.

Estado ocupacional

Salidas fuera del hogar

Column 2

Medidas de protección

Prevención

Column 1

Resumen

Medidas de prevención personales

"La edad de las personas no pareció influir en la percepción de riesgo o preocupación en la salud personal.

Los participantes reportaron en su mayoria utilizar las mascarillas en todo momento al salir de casa y/o en lugares conglomerados."

Percepción del riesgo

Preocupación sobre su salud

Column 2

Medidas de protección personal

Salud Personal

Column 1

Resumen

Salud personal

"537 personas encuestadas reportaron tener resultado diagnóstico para COVID-19.

Se ve una relación inversa al número de pruebas realizadas y el resultado diagnóstico de aquellos que accedieron a las pruebas según el ingreso familiar de la persona.

A mayor ingreso familiar, la proporción de personas que se hicieron la prueba fue mayor. Sin embaro, a menor ingreso familiar la proporción de resultados positivos es mayor.

Un grupo importante de personas reporto sentirse “nervioso o ansioso”, asi como “tener poco interés o placer al realizar actividades cotidianas” durante varios días de la semana."

Percepción del riesgo

Prueba según ingreso

Resultado según ingreso

Column 2

Salud Mental

---
title: "1ra Ronda ICPCovid - Perú"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
    social: menu
    theme: cosmo
    self_contained: TRUE
    fig_mobile: TRUE
---


```{r}
library(flexdashboard)
library(readr)
library(haven)
library(tidyr)
library(dplyr)
library(stringr)
library(skimr)
library(sf)
library(rmapshaper)
library(tidyverse)
library(viridis)
library(ggiraphExtra)
library(png)
library(grid)
library(ggplot2)
library(scales)
library(alluvial)
library(ggalluvial)
library(fmsb)
library(hrbrthemes)
library(ggwaffle)
library(waffle)
library(waffle)
library(extrafont)
library(tidyverse)
library(ggpubr)
library(plyr)
library(Hmisc)
library(Gmisc)
library(magrittr)
library(codebook)
library(future)
library(abd)
library(epitools)
library(magrittr)
library(qwraps2)
```

```{r}
data <- read.csv("../Output/ICPCovid_r1_0728.csv")
```

```{r, class.output="scroll-100", error=F, warning=F, echo=F, message=F,include=F}
shp <- st_read("../Data/shapefile_distr", stringsAsFactors = F)%>%
  st_transform(4326) %>% 
  dplyr::select(reg = NOMBDEP,
                prov = NOMBPROV,
                distr = NOMBDIST)%>%
  ms_simplify(keep=0.2)%>%
  dplyr::mutate(distr =gsub("_", " ",gsub("-", " ", iconv(distr,
               from="UTF-8",
               to="ASCII//TRANSLIT"), fixed=TRUE), fixed=TRUE),
         prov = iconv(prov,
               from="UTF-8",
               to="ASCII//TRANSLIT"),
         reg = iconv(reg,
               from="UTF-8",
               to="ASCII//TRANSLIT")
         ) %>%
  dplyr::mutate(distr = ifelse(distr=="HUAYA","HUALLA",
                      ifelse(distr=="MAZAMARI   PANGOA","MAZAMARI",
                             ifelse(distr=="LARAOS" & prov=="HUAROCHIRI","SAN PEDRO DE LARAOS",distr))))

shp.nac <- st_read("../Data/Limite_departamental", stringsAsFactors = F)%>%
  st_transform(4326) %>% 
  dplyr::select(reg = NOMBDEP)%>%
  ms_simplify(keep=0.2)%>%
  dplyr::mutate(reg = iconv(reg,
               from="UTF-8",
               to="ASCII//TRANSLIT")
         ) 

 shp.prov <- st_read("../Data/shapefile_prov", stringsAsFactors = F)%>%
   st_transform(4326) %>% 
   dplyr::select(prov = PROVINCIA)%>%
   ms_simplify(keep=0.2)%>%
   dplyr::mutate(prov = iconv(prov,
                from="UTF-8",
                to="ASCII//TRANSLIT")
          ) 

```

```{r config_lima, error=F, warning=F, echo=F, message=F}
my_breaks <- c(0, 100, 250, 500)
breaks_nac <- c(0, 50, 125, 250)
data.shp.lima <- merge(shp %>%
                         dplyr::filter(prov=="LIMA" | prov=="CALLAO"),
                       data %>% 
                         dplyr::filter(reg=="LIMA"| reg=="CALLAO"), by=c("reg","distr"),all.x=T)
data.shp.nac <- merge(shp.nac %>% 
                        dplyr::select(reg),
                      data %>% filter(reg !="LIMA") %>%
                        dplyr::select(reg), by=c("reg"),all=T)
shapefile_prov_lima <-shp.prov %>% dplyr::filter(prov=="LIMA"| prov=="CALLAO" )  

rm(shp,shp.nac, shp.prov)

```


```{r, error=F, warning=F, echo=F, message=F}
vida_diaria <- data %>% dplyr::select(age,info_newspaper2,info_socialmedia2
,info_offiweb2
,info_tv2
,info_radio2
,info_null2
,lastphysical3
,food_diffic2
,time_child2
,play_child2
,homework_child2
,annoy_child2
,food2
,child_outhome2
)



salud_personal <- data %>%  dplyr::select(income3,age,gender2,symp_fever2
,symp_headache2
,symp_sorethr2
,symp_taste2
,symp_smell2
,symp_nasalc2
,symp_drycough2
,symp_prodcough2
,symp_chest2
,symp_breath2
,symp_muscle2
,symp_weak2
,symp_nausea2
,symp_diarrea2
,symp_lossapet2
,symp_nosymp2
,symp_house3
,closecov_house2
,closecov_office2
,closecov_vehicle2
,closecov_nocont2
,closecov_unknown2
,covtest3
,testresult3
,testwhy3
,testwhen3
,risk2
,worry2
,smoke3
,b_heart2
,b_hyperten2
,b_diabetes2
,b_cancer2
,b_hiv2
,b_tb2
,b_asthma2
,b_obese2
,b_none2
,b_followup3
,nervanx3
,stopworry3
,littinter3
,sad3
,opinion3
,nobonus2
,ybonus_food2
,ybonus_fam2
,ybonus_pers2
,nomask_unknownget2
,nomask_uncomfy2
,nomask_noneed2
,satinitizer3
,avoidtouch3
)


```

```{r, error=F, warning=F, echo=F, message=F}
salud_personal$covtest <- relevel(salud_personal$covtest, "Si")

label(salud_personal$risk) <- "¿Cuál es el riesgo que ya tenga COVID-19 o que se infecte pronto?"


#label(salud_personal$symp_fever) <- "He tenido fiebre"

salud_personal$symp_fever <- relevel(salud_personal$symp_fever, "Si")
salud_personal$symp_headache <- relevel(salud_personal$symp_headache, "Si")
salud_personal$symp_sorethr <- relevel(salud_personal$symp_sorethr, "Si")
salud_personal$symp_taste <- relevel(salud_personal$symp_taste, "Si")
salud_personal$symp_smell <- relevel(salud_personal$symp_smell, "Si")
salud_personal$symp_nasalc <- relevel(salud_personal$symp_nasalc, "Si")
salud_personal$symp_drycough <- relevel(salud_personal$symp_drycough, "Si")
salud_personal$symp_prodcough <- relevel(salud_personal$symp_prodcough, "Si")
salud_personal$symp_chest <- relevel(salud_personal$symp_chest, "Si")
salud_personal$symp_breath <- relevel(salud_personal$symp_breath, "Si")
salud_personal$symp_muscle <- relevel(salud_personal$symp_muscle, "Si")
salud_personal$symp_weak <- relevel(salud_personal$symp_weak, "Si")
salud_personal$symp_nausea <- relevel(salud_personal$symp_nausea, "Si")
salud_personal$symp_diarrea <- relevel(salud_personal$symp_diarrea, "Si")
salud_personal$symp_lossapet <- relevel(salud_personal$symp_lossapet, "Si")


data$outhome3<- factor(data$outhome3, levels = c("Nunca","Una vez","Dos veces","Tres o más veces","Todos los días"))

```


Sociodemográfico {.bg}
=====================================  

Column 1 {data-width=250} 
-------------------------------------
### `r paste0('Encuestados de regiones y distritos no adscritos a Lima Metropolitana')`

```{r}
valueBox(paste0('1,041'),  
           icon = "fa-male",
           color = '#a35fb8')
```

### `r paste0("Encuestados de Lima Metropolitana")`

```{r}
valueBox(paste0('2,378'),  
           icon = "fa-male",
           color = '#a35fb8')
```


### Resumen

#### Encuesta Ciudadana ICPCovid

"Los gráficos a continuación son el resultado de la primera encuesta ciudadana ICPCovid realizada en Perú durante la 2da semana de junio de 2020.

En total participaron 3419 personas de distintos distritos, provincias y regiones del Perú."


Column 2 {.tabset } 
-------------------------------------

### Características

```{r}
####################
### Pyramid Plot ###
####################

# Subset y arreglo de datos
cols <- c("#2864b4","#ffad26")

pyramid_data <- data %>% 
  dplyr::select(edad = age,
                nm_sex = gender2) %>% 
  dplyr::filter(nm_sex!=3)
pyramid_data$nm_sex <- as.factor(pyramid_data$nm_sex)

pyramid_data <- pyramid_data %>%
  dplyr::filter(!is.na(edad)) %>%
  dplyr::mutate(Hombre = if_else(as.integer(nm_sex)==2,1,0),
         Mujer = if_else(as.integer(nm_sex)==1,1,0)) %>%
  group_by(edad) %>%
  dplyr::summarise(Hombre = sum(Hombre),Mujer = sum(Mujer)) %>%
  dplyr::mutate(edad = if_else(edad>=18 & edad<25,"18 a 24",
                          if_else(edad>=25 & edad<35,"25 a 34",
                                  if_else(edad>=35 & edad<45,"35 a 44",
                                          if_else(edad>=45 & edad<55,"45 a 54",
                                                  if_else(edad>=55 & edad<65,"55 a 65",
                                                          if_else(edad>=65 & edad<75,"65 a 74",
                                                                  if_else(edad>=75,"75 o +","ERROR"))))))))

pyramid_data$edad <- factor(pyramid_data$edad, 
                            levels = pyramid_data$edad,
                            labels =pyramid_data$edad)

# Grafico de piramide poblacional (edad y sexo)
ggplot(pyramid_data) +      
  geom_bar(aes(x=edad, y=Mujer, fill="Mujer"), stat="identity") +                                                
  geom_bar(aes(x=edad, y=-Hombre, fill="Hombre"), stat="identity") +     
  coord_flip() +                                                             
  theme_minimal() +
  labs(title = "Información demográfica", 
       x = "Grupos de edad", 
       y = "", 
       color = "Sexo") + 
  scale_fill_manual(values= cols, 
                       name="")+ 
  scale_y_continuous(limits = c(-600,600),
                     breaks = seq(-600, 600, 200), 
                     labels = paste0(as.character(c(seq(600, 0, -200), seq(100, 600, 200))))) +
  theme(
        plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=18),
        axis.title.y =  element_text(
                                  size=14),
        axis.text=element_text(size=12),
        legend.title = element_text(face = "bold"),
        legend.position="bottom",
        legend.text=element_text(size=10),
        panel.grid.major = element_blank(), panel.grid.minor = element_blank())


```


Column 3 {.tabset  data-width=350} 
-------------------------------------

### Perú
```{r, class.output="scroll-100", error=F, warning=F, echo=F, message=F, fig.height=10}
data.shp.nac %>% group_by(reg) %>% dplyr::summarise(n=n()) %>%
  ggplot() + 
  geom_sf(aes(fill=n))+ 
  scale_fill_gradient(name = "",
                      trans = scales::pseudo_log_trans(sigma = 100),
                      limits=c(0,250),
                      high="#ffad26", low="#ebebeb",
                      breaks=breaks_nac, labels=breaks_nac#, 
                      #guide = "legend"
)+
  theme_minimal() + 
  theme(axis.title.x=element_blank(),axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),axis.ticks.y=element_blank(),
        plot.margin = margin(0,0,0,0),
        legend.position=c(0.8,0.9),
        legend.text= element_text(size=15),
        legend.direction = "horizontal",
        legend.box.margin=margin(0,0,0,0),
        
       ) + 
  geom_sf(data= shapefile_prov_lima,fill="Black") + 
  theme(legend.key.size = unit(0.75, "cm"))
```

### Lima Metropolitana

```{r, fig.height=10}
data.shp.lima %>% group_by(distr) %>% dplyr::summarise(n=n()) %>%
  ggplot() + 
  geom_sf(aes(fill=n))+ 
  scale_fill_gradient(name = "",
                      trans = scales::pseudo_log_trans(sigma = 100),
                      limits=c(0,500),
                      high="#2864b4", low="#ebebeb",
                      breaks=my_breaks, labels=my_breaks#, 
                      #guide = "legend"
)+
  theme_minimal() + 
  theme(axis.title.x=element_blank(),axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),axis.ticks.y=element_blank(),
        plot.margin = margin(0,0,0,0),
        legend.position=c(0.8,0.9),
        legend.text= element_text(size=15),
        legend.direction = "horizontal",
        legend.box.margin=margin(0,0,0,0),
        
       )+ theme(legend.key.size = unit(0.75, "cm"))
```

Vida Diaria {data-orientation=rows}
=====================================  

Column 1 
-------------------------------------
### Resumen 

#### Vida diaria durante la cuarentena

"La mayoría de personas reportó informarse a través de fuentes o medios oficiales en la web, seguido de redes sociales y la televisión. En menor medida, algunos mencionaron el uso de periódico y radio.

Al momento de la encuesta, casi la totalidad de los participantes mencionaron utilizar mascarillas al salir de sus casas. Asimismo, solo el ~20% de los niños salían de sus hogares.

La mayoria de personas solo salían una o dos veces de su hogar para dirigirse a mercados, farmacias o bancos. Aquellos que salieron tres o más veces se dirigieron principalmente a sus centros laborales."

### Medios de información

```{r}
helperFunction <- function(x){
    ifelse(x=="Si", 1,0)
}


info.df<- data %>% dplyr::select(`Periódico` = info_newspaper2,
                               `Webs\nOficiales` =info_offiweb2,
                                Radio =info_radio2,
                                `Redes\nSociales`=info_socialmedia2,
                                `Televisión`=info_tv2)%>% 
  mutate_if(is.factor, as.character) %>% 
  mutate_all(helperFunction) %>%
  dplyr::summarise_all(sum,na.rm=T) %>%
  gather(info, n, `Periódico`:`Televisión`, factor_key=TRUE) %>%
  dplyr::mutate(n = n/nrow(data))

p.order <- info.df %>% arrange(desc(n)) %>% pull(info)

info.df.n<- info.df %>% 
    transform(info=factor(info,levels=p.order)) %>%
  ggplot(aes(x=info, y=n, fill=info)) +
  geom_bar(stat="identity")+theme_minimal() + scale_fill_manual(values =c("#2864b4","#a35fb8","#ef5996","#ff765f","#ffad26"))+ 
  scale_y_continuous(labels = percent, limits=c(0,0.8)) + 
  theme(legend.position = "none") +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=23),
        #axis.title.y =  element_text(
        #                          size=16),
        axis.text=element_text(size=16),
        panel.grid.major = element_blank(), panel.grid.minor = element_blank()#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "Fuentes y medios\nde información más frecuentados", 
       x = "", 
       y = "", 
       color = "")

gob.img <- readPNG("../Data/icons/gob.png")
gob.img <- rasterGrob(gob.img, interpolate=TRUE)
gob.pos <- info.df %>% filter(info=="Webs\nOficiales") %>% pull(n)

web.img <- readPNG("../Data/icons/domain.png")
web.img <- rasterGrob(web.img, interpolate=TRUE)
web.pos <- info.df %>% filter(info=="Redes\nSociales") %>% pull(n)

tv.img <- readPNG("../Data/icons/tv.png")
tv.img <- rasterGrob(tv.img, interpolate=TRUE)
tv.pos <- info.df %>% filter(info=="Televisión") %>% pull(n)

radio.img <- readPNG("../Data/icons/radio.png")
radio.img <- rasterGrob(radio.img, interpolate=TRUE)
radio.pos <- info.df %>% filter(info=="Radio") %>% pull(n)

news.img <- readPNG("../Data/icons/periodico.png")
news.img <- rasterGrob(news.img, interpolate=TRUE)
news.pos <- info.df %>% filter(info=="Periódico") %>% pull(n)

info.df.n <- info.df.n +
  annotation_custom(gob.img,xmin=1+1,xmax=1-1, ymin=gob.pos+0.02, ymax=gob.pos+0.12)+
  annotation_custom(tv.img,xmin=3+1,xmax=3-1, ymin=tv.pos+0.02, ymax=tv.pos+0.12)+
  annotation_custom(radio.img,xmin=5+1,xmax=5-1, ymin=radio.pos+0.02, ymax=radio.pos+0.12)+
  annotation_custom(news.img,xmin=4+1,xmax=4-1, ymin=news.pos+0.02, ymax=news.pos+0.12)+
  annotation_custom(web.img,xmin=2+1,xmax=2-1, ymin=web.pos+0.02, ymax=web.pos+0.12) + 
  coord_flip()



info.df.n
```

### Uso de mascarilla

```{r}
mask.usage <- data %>% 
  group_by(mask3) %>% 
  dplyr::summarise(n = n()) %>%
  dplyr::mutate(n_por = round(n/sum(n)*500),
                mask3 = as.factor(ifelse(as.character(mask3)=="Si","Si usó mascarilla",
                                         ifelse(as.character(mask3)=="No aplica (no salgo de casa)","No sale de casa","No usó mascarilla")
  )))
  
  mask.usage$mask3 <- relevel(mask.usage$mask3, "No usó mascarilla")
  
mask.pic <- mask.usage%>%
    arrange(desc(n_por)) %>%
  ggplot(aes(label = mask3, values = n_por)) +
  geom_pictogram(n_rows = 25, aes(colour = mask3), flip = TRUE, make_proportional = F,
    family = "FontAwesome", size =4)  +
  theme_clean() +
  theme_enhance_waffle()+
  scale_label_pictogram(
    name = NULL,
    values = c("male", "male", "male"),
    labels = c("No usó mascarilla", "No sale de casa","Si usó mascarilla")
  )+
  scale_color_manual(
    name = NULL,
    values = c( "#ff765f", "#ffa600","#0e5871"),
    labels = c("No usó mascarilla", "No sale de casa","Si usó mascarilla")
  ) +
    labs(title="Uso de mascarilla\nal salir de casa",
         subtitle="1 en 342 participantes reportó no usar mascarilla al salir",
         caption="*Representadas 499 personas"
    ) +
  theme(legend.key.height = unit(2.25, "line")) +
    theme(plot.margin = unit(c(0,0,0,0), "cm"),
          plot.title = element_text(size=23,hjust = 0.5, vjust=0,face="bold"),
          plot.subtitle = element_text(hjust = 0.5)) 

mask.pic
```

### Niños fuera de casa

```{r}
data %>% 
  filter(!is.na(child_outhome2)) %>%
  group_by(child_outhome2) %>%
  dplyr::summarise(n=n()) %>%
  ungroup() %>% mutate(n=round(n/nrow(data %>% 
                                  filter(!is.na(child_outhome2)))*100, digits = 2)) %>%
  ggplot(aes(x="", y=n, fill=child_outhome2))+
  geom_bar(width = 1, stat = "identity")+ 
  coord_polar("y", start=0)+  
  theme_clean() +
  theme(axis.text.x=element_blank(),
        plot.margin = unit(c(0,0,0,0), "cm"),
          plot.title = element_text(size=23,hjust = 0.5, vjust=0,face="bold")) +
    labs(title="¿Los niños salieron de casa\nen la última semana?",
         subtitle="",
         caption="*Total de respuestas: 1535",
         fill="Respuesta:"
    )+ scale_fill_manual(values=c("#ffad26","#2864b4")) +
  geom_text(aes(y = n-10, 
                label = n, 
                size=30),
            show.legend = FALSE
            )
```

Column 2 {.tabset} 
-------------------------------------

### Destinos

```{r, fig.width=15}
alluvial_plot<-data %>% dplyr::select(outhome3,
                     `Mercados y/o Supermercados`=place_markets_supermarkets,
                     `Hospital`=place_hospital2,
                     `Farmacia`=place_Farmacy2,
                     `Banco`=place_bank2,
                     `Trabajo`=place_work2,
                     `Visitas`=place_visit2,
                     `Paseos`=place_walkexe2,
                     Otros = place_other_mix2)%>%
  group_by(outhome3)%>% 
  mutate_if(is.factor, as.character) %>% 
  mutate_all(helperFunction) %>%
  dplyr::summarise_all(sum,na.rm=T) %>%
  gather(place, n, `Mercados y/o Supermercados`:Otros, factor_key=TRUE) %>%
  filter(n!=0) 


p.order.place<- alluvial_plot %>% group_by(place) %>%dplyr::mutate(n=sum(n)) %>% arrange(desc(n)) %>% pull(place) %>% unique(.)

alluvial_plot<-alluvial_plot %>%
  dplyr::mutate(place = factor(place,levels=p.order.place,labels = p.order.place))

#is_alluvia_form(alluvial_plot)

alluvial_plot_plot <- ggplot(alluvial_plot,
       aes(y=n,axis1=place,axis2=outhome3)) +
  geom_alluvium(aes(fill=outhome3),width=1/20) + 
  geom_stratum(width=1/9)+
  geom_text(size=5,stat="stratum",aes(label=after_stat(stratum)))+
  scale_x_discrete(limits=c("Número de salidas","Destino"),expand=c(.1,.1))+
  theme_minimal() +
  theme(legend.position = "right") +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=26),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=22),
        axis.title.y =  element_text(
                                  size=22,
                                  hjust = 0.5),
        axis.title.x =  element_text(
                                  size=22),
        axis.text=element_text(size=14),
        axis.text.y = element_blank(),
        axis.text.x = element_blank(),
        panel.grid.major = element_blank(), panel.grid.minor = element_blank()#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "Lugares de movilización",
       subtitle= "¿Cuántas veces?",
       y = "¿A dónde?", 
       fill = "") + 
  coord_flip() + 
  scale_fill_manual(values = c("#2864b4","#a35fb8","#ef5996","#ff765f","#ffad26")) + 
  theme(legend.position = "none")

alluvial_plot_plot
```


Vida Profesional {data-orientation=rows}
=====================================  

Column 1 
-------------------------------------
### Resumen 

#### Vida laboral y profesional durante la pandemia

"La pandemia y, en consecuencia, la cuarentena, afectó en mayor proporción a aquellos encuestados que reportaron un menor ingreso familiar. Aquellos con menores ingresos familiares dejaron de estudiar o trabajar más que aquellos con mayores ingresos.

No hubieron diferencias visuales significativas entre el ingreso familiar promedio y el número de salidas fuera del hogar.

La principal medida de protección de los centros laborales fue el que sus trabajadores permanezcan en casa. 


### Estado ocupacional

```{r}
df_house_comp <- data %>% 
  dplyr::select(work_before2,income3,work_change3,outhome3) %>%
  mutate(income = as.factor(income3),
         work_change = as.factor(work_change3))

data$work_change3 <- revalue(data$work_change3, c("No, me he mantenido en la misma ocupación"="Sin cambios"))
data$work_change3 <- revalue(data$work_change3, c("Si, antes estudiaba"="Antes estudiaba"))
data$work_change3 <- revalue(data$work_change3, c("Si, antes trabajaba"="Antes trabajaba"))
data$work_change3 <- revalue(data$work_change3, c("Si, antes estudiaba y trabajaba"="Antes estudiaba\ny trabajaba"))
data$income3 <- revalue(data$income3, c("S/12,660 o más"="S/12,660\no más"))
data$income3 <- revalue(data$income3, c("S/1,300 o menos"="S/1,300\no menos"))




data$income3 <- factor(data$income3, 
                       levels = c("S/1,300\no menos","S/2,480", "S/3,970","S/7,020","S/12,660\no más"))
data$work_change3 <- factor(data$work_change3, 
                            levels = c("Sin cambios", "Antes estudiaba", "Antes trabajaba","Antes estudiaba\ny trabajaba"))


data %>% group_by(income3,work_change3) %>% dplyr::summarise(n=n())%>% ungroup()%>% 
  ggplot(aes(x=income3, y=n, fill=work_change3))  +
  geom_bar(stat="identity",position="fill")+ 
  scale_fill_manual(values = c("#2864b4","#c05bb0","#ff6872","#ffad26")) +
  scale_y_continuous(labels = percent)+
  theme_clean()  +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10)#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "Cambios de ocupación por la pandemia\nsegún ingreso familiar",
       subtitle="",
       x = "Ingreso familiar promedio", 
       y = "", 
       fill = "Cambios de ocupación")


```

### Salidas fuera del hogar

```{r}
data %>% select(outhome3,income3) %>% 
  group_by(income3,outhome3) %>% 
  dplyr::summarise(n=n()) %>% ungroup()%>% 
  ggplot(aes(x=income3, y=n, fill=outhome3))  +
  geom_bar(stat="identity",position="fill")+ 
  scale_fill_manual(values = c("#2864b4","#a35fb8","#ef5996","#ff765f","#ffad26")) +
  scale_y_continuous(label=percent)+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10)#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "Número de salidas por semana\nsegún ingreso familiar",
       subtitle="",
       x = "Ingreso familiar promedio", 
       y = "", 
       fill = "¿Cuantas veces salió\nde casa?") 

```


Column 2 
-------------------------------------
### Medidas de protección 

```{r, fig.width=20}
data$whealth_stayhome2 <- relevel(data$whealth_stayhome2, "Si")
data$whealth_mask2 <- relevel(data$whealth_mask2, "Si")
data$whealth_respirator2 <- relevel(data$whealth_respirator2, "Si")
data$whealth_gloves2 <- relevel(data$whealth_gloves2, "Si")
data$whealth_face2 <- relevel(data$whealth_face2, "Si")
data$whealth_apron2 <- relevel(data$whealth_apron2, "Si")
data$whealth_none2 <- relevel(data$whealth_none2, "Si")


a <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(whealth_stayhome2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=whealth_stayhome2, y=n, fill=whealth_stayhome2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Permaneció en casa",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2250))

b <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(whealth_mask2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=whealth_mask2, y=n, fill=whealth_mask2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Le proporcionaron una\nmascarilla quirúrgica",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2250))



c <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(whealth_respirator2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=whealth_respirator2, y=n, fill=whealth_respirator2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Le proporcionaron un\nrespirador (N95, KN95, etc.)",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2250))

d <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(whealth_gloves2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=whealth_gloves2, y=n, fill=whealth_gloves2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Le proporcionaron\nguantes",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2250))

e <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(whealth_face2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=whealth_face2, y=n, fill=whealth_face2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Le proporcionaron\nprotector facial",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2250))

f <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(whealth_apron2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=whealth_apron2, y=n, fill=whealth_apron2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Le proporcionaron\nmandil",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2250))

ggarrange(a, b, c,d,e,f,
          ncol = 6, nrow = 1) %>%
annotate_figure(top = text_grob("Medidas de protección entregadas por centros laborales\n(opción múltiple)", face="bold",size = 18),
               bottom = text_grob("Total de personas que respondieron estas preguntas: 2,343", face = "italic", size = 8)
)


```


Prevención {data-orientation=rows}
=====================================  

Column 1 
-------------------------------------
### Resumen 

#### Medidas de prevención personales

"La edad de las personas no pareció influir en la percepción de riesgo o preocupación en la salud personal.

Los participantes reportaron en su mayoria utilizar las mascarillas en todo momento al salir de casa y/o en lugares conglomerados."

### Percepción del riesgo 

```{r, error=F, warning=F, echo=F, message=F}
stay_home_age <-data %>% dplyr::select(age,risk2) %>% filter(!is.na(risk2)) %>%
  dplyr::mutate(risk2 = ifelse(risk2=="Muy poco o riesgo nulo","Muy Poco o nulo\nRiesgo",
                                       ifelse(risk2=="Poco riesgo","Poco\nRiesgo",
                                       ifelse(risk2=="Mediano riesgo","Mediano\nRiesgo",
                                       ifelse(risk2=="Alto riesgo","Alto\nRiesgo",
                                       ifelse(risk2=="Muy alto riesgo","Muy Alto\nRiesgo","error"
                                              )) )))) %>%
  ggplot(aes(x=risk2,y=age)) +
  geom_violin()+ stat_summary(fun.data=mean_sdl, mult=1, 
                 geom="pointrange", color="red") + 
  coord_flip()



stay_home_age <-data %>% dplyr::select(age,risk2) %>% filter(!is.na(risk2)) %>%
  dplyr::mutate(risk2 = ifelse(risk2=="Muy poco o riesgo nulo","Muy Poco o nulo\nRiesgo",
                                       ifelse(risk2=="Poco riesgo","Poco\nRiesgo",
                                       ifelse(risk2=="Mediano riesgo","Mediano\nRiesgo",
                                       ifelse(risk2=="Alto riesgo","Alto\nRiesgo",
                                       ifelse(risk2=="Muy alto riesgo","Muy Alto\nRiesgo","error"
                                              )) ))),
         risk2 = factor(risk2,levels = c("Muy Poco o nulo\nRiesgo","Poco\nRiesgo","Mediano\nRiesgo","Alto\nRiesgo","Muy Alto\nRiesgo"))) %>%
  ggplot(aes(x=risk2,y=age)) +
  geom_violin(aes(fill=risk2, alpha=1.5))+ 
  scale_fill_manual(values = c("#2864b4","#a35fb8","#ef5996","#ff765f","#ffad26")) +
  scale_y_continuous(breaks=c(20,40,60,80))+
  theme_clean() + 
  theme(legend.position = "none") +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10)#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "",
       subtitle="¿Cuál es el riesgo que ya tenga COVID-19\no que se infecte pronto?",
       x = "", 
       y = "Edad", 
       fill = "") + 
  geom_boxplot(fill=NA,width=0.4, color="#f1f1f1")

stay_home_age

```

### Preocupación sobre su salud 

```{r}
stay_home_age <- data %>% dplyr::select(age,worry2) %>% filter(!is.na(worry2)) %>%
  dplyr::mutate(worry2 = ifelse(worry2=="Nada preocupado","Nada\nPreocupado",
                                       ifelse(worry2=="Un poco preocupado","Un poco\npreocupado",
                                       ifelse(worry2=="Moderadamente preocupado","Moderadamente\nPreocupado",
                                       ifelse(worry2=="Muy preocupado","Muy\nPreocupado",
                                       ifelse(worry2=="Extremadamente preocupado","Extremadamente\nPreocupado","error"
                                              )) ))),
         worry2 = factor(worry2,levels = c("Nada\nPreocupado","Un poco\npreocupado","Moderadamente\nPreocupado",
                                           "Muy\nPreocupado","Extremadamente\nPreocupado"))) %>%
  filter(!is.na(worry2)) %>%
  ggplot(aes(x=worry2,y=age)) +
  geom_violin(aes(fill=worry2, alpha=0.98))+ 
  scale_fill_manual(values = c("#2864b4","#a35fb8","#ef5996","#ff765f","#ffad26")) +
  scale_y_continuous(breaks=c(20,40,60,80))+
  theme_clean() + 
  theme(legend.position = "none") +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10)#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "",
       subtitle="¿Cuán preocupado ha estado por su salud\ndurante la última semana?",
       x = "", 
       y = "Edad", 
       fill = "") + 
  geom_boxplot(fill=NA,width=0.4, color="#f1f1f1")

stay_home_age
```


Column 2
-------------------------------------

### Medidas de protección personal 

```{r, fig.width=20}
data$mask_crowdedplace2 <- relevel(data$mask_crowdedplace2, "Si")
data$mask_work2 <- relevel(data$mask_work2, "Si")
data$mask_pubtransp2 <- relevel(data$mask_pubtransp2, "Si")
data$mask_alltime2 <- relevel(data$mask_alltime2, "Si")
data$mask_home2 <- relevel(data$mask_home2, "Si")


a <- data %>% filter(as.character(mask3) =="Si") %>%
  group_by(mask_crowdedplace2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=mask_crowdedplace2, y=n, fill=mask_crowdedplace2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="En lugares conglomerados",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))

b <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(mask_work2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=mask_work2, y=n, fill=mask_work2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="En el trabajo",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))



c <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(mask_pubtransp2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=mask_pubtransp2, y=n, fill=mask_pubtransp2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="En el transporte público",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))

d <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(mask_alltime2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=mask_alltime2, y=n, fill=mask_alltime2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="En todo momento,\ncuando salgo de casa",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))

e <- data %>% filter(as.character(whealth_na2) =="No") %>%
  group_by(mask_home2) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=mask_home2, y=n, fill=mask_home2)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="En todo momento,\nincluso dentro de casa",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#ffad26","#2864b4"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))

ggarrange(a, b, c,d,e,
          ncol = 5, nrow = 1) %>%
annotate_figure(top = text_grob("¿Cúando y dónde utiliza las mascarillas?\n(opción múltiple)", face="bold",size = 18),
               bottom = text_grob("Total de personas que respondieron estas preguntas: 3,134", face = "italic", size = 8)
)

```




Salud Personal {data-orientation=rows}
=====================================  

Column 1 
-------------------------------------
### Resumen 

#### Salud personal

"537 personas encuestadas reportaron tener resultado diagnóstico para COVID-19.

Se ve una relación inversa al número de pruebas realizadas y el resultado diagnóstico de aquellos que accedieron a las pruebas según el ingreso familiar de la persona.

A mayor ingreso familiar, la proporción de personas que se hicieron la prueba fue mayor. Sin embaro, a menor ingreso familiar la proporción de resultados positivos es mayor.

Un grupo importante de personas reporto sentirse "nervioso o ansioso", asi como "tener poco interés o placer al realizar actividades cotidianas" durante varios días de la semana."

### Percepción del riesgo 

```{r}
data %>% filter(as.character(gender2) != "Prefiero no indicarlo")%>%group_by(gender2,covtest3) %>% dplyr::summarise(n=n()) %>%
ggplot(aes(x=gender2, y=n, fill=covtest3)) +
  geom_bar(stat="identity",position="fill")+
  theme_minimal()+
    labs(title="Pruebas diagnósticas\nsegún sexo",
         subtitle="¿Se ha realizado prueba diagnóstica para COVID-19?",
         caption="",
         fill="",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#2864b4","#ffad26"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16,face="bold"),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10))

```

### Prueba según ingreso


```{r}
data %>% group_by(income3,covtest3) %>% dplyr::summarise(n=n()) %>%
ggplot(aes(x=income3, y=n, fill=covtest3))+
  geom_bar(stat="identity",position="fill")+ 
  scale_fill_manual(values = c("#2864b4","#ffad26")) +
  scale_y_continuous(label=percent)+
  theme_clean()  +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10)#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "Pruebas diagnósticas realizadas\nsegún ingreso familiar",
       subtitle="",
       x = "Ingreso familiar promedio", 
       y = "", 
       fill = "¿Se realizó diagnóstico?")
```

### Resultado según ingreso

```{r}
data%>% filter(as.character(covtest3) == "Si" & as.character(testresult3) != "Resultado pendiente") %>% group_by(income3,testresult3) %>% dplyr::summarise(n=n()) %>%
ggplot(aes(x=income3, y=n, fill=testresult3))+
  geom_bar(stat="identity",position="fill")+ 
  scale_fill_manual(values = c("#2864b4","#ffad26")) +
  scale_y_continuous(label=percent)+
  theme_clean()  +
  theme(plot.title = element_text(hjust = 0.5, 
                                  face="bold",
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10)#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+
  labs(title = "Resultado diagnóstico\nsegún ingreso familiar",
       subtitle="N=537",
       x = "Ingreso familiar promedio", 
       y = "", 
       fill = "Resultado diagnóstico")
```


Column 2
-------------------------------------

### Salud Mental

```{r, fig.width=20}
data$nervanx3 <- revalue(data$nervanx3, c("En ningún momento"="En ningún\nmomento",
                                          "Más de la mitad de los días de la semana"="Más de la mitad\nde los días",
                                          "Casi todos los días"="Casi todos\nlos días"))

data$stopworry3 <- revalue(data$stopworry3, c("En ningún momento"="En ningún\nmomento",
                                          "Más de la mitad de los días de la semana"="Más de la mitad\nde los días",
                                          "Casi todos los días"="Casi todos\nlos días"))
data$littinter3 <- revalue(data$nervanx3, c("En ningún momento"="En ningún\nmomento",
                                          "Más de la mitad de los días de la semana"="Más de la mitad\nde los días",
                                          "Casi todos los días"="Casi todos\nlos días"))
data$sad3 <- revalue(data$sad3, c("En ningún momento"="En ningún\nmomento",
                                          "Más de la mitad de los días de la semana"="Más de la mitad\nde los días",
                                          "Casi todos los días"="Casi todos\nlos días"))

data$nervanx3 <- factor(data$nervanx3, 
                        levels = c("En ningún\nmomento","Varios días",
                                   "Más de la mitad\nde los días","Casi todos\nlos días"))

data$stopworry3 <- factor(data$stopworry3, 
                        levels = c("En ningún\nmomento","Varios días",
                                   "Más de la mitad\nde los días","Casi todos\nlos días"))

data$littinter3 <- factor(data$littinter3, 
                        levels = c("En ningún\nmomento","Varios días",
                                   "Más de la mitad\nde los días","Casi todos\nlos días"))

data$sad3 <- factor(data$sad3, 
                        levels = c("En ningún\nmomento","Varios días",
                                   "Más de la mitad\nde los días","Casi todos\nlos días"))

a <- data  %>%
  group_by(nervanx3) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=nervanx3, y=n, fill=nervanx3)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Se ha sentido\nnervioso o ansioso",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#2864b4","#c05bb0","#ff6872","#ffad26"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))

b <- data %>%
  group_by(stopworry3) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=stopworry3, y=n, fill=stopworry3)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="No pudo detener o controlar\nsus preocupaciones",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#2864b4","#c05bb0","#ff6872","#ffad26"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))



c <- data %>%
  group_by(littinter3) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=littinter3, y=n, fill=littinter3)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Tuvo poco interés o placer\nal realizar actividades cotidianas",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#2864b4","#c05bb0","#ff6872","#ffad26"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))

d <- data %>%
  group_by(sad3) %>%
  dplyr::summarise(n=n()) %>%
  ggplot(aes(x=sad3, y=n, fill=sad3)) +
  geom_bar(stat="identity")+theme_minimal()+
    labs(title="Se sintió triste,\ndeprimido o sin esperanza",
         subtitle="",
         caption="",
         fill="Respuesta:",
         x="",
         y=""
    )+ scale_fill_manual(values=c("#2864b4","#c05bb0","#ff6872","#ffad26"))+
  theme_clean() +
  theme(plot.title = element_text(hjust = 0.5,
                                  size=16),
        plot.subtitle = element_text(hjust = 0.5,
                                  size=14),
        axis.title.y =  element_text(
                                  size=14),
        axis.title.x =  element_text(
                                  size=14),
        axis.text=element_text(size=10),
          plot.margin=margin(1,0,0,0,"cm")#,
        #legend.title = element_text(face = "bold"),
        #legend.position="bottom",
        #legend.text=element_text(size=16)
        )+ 
  theme(legend.position = "none")+
  scale_y_continuous(limits=c(0, 2500))


ggarrange(a, b, c,d,
          ncol = 4, nrow = 1) %>%
annotate_figure(top = text_grob("Durante las últimas 2 semanas\n¿Con qué frecuencia se ha sentido fastidiado por los siguientes problemas?", face="bold",size = 18))

```